﻿#include "pch.h"
#include "幻想神域mfc.h"
#include "HXSYDialog.h"
#include "afxdialogex.h"
#include "call.h"
#include "hook.h"
#include "func.h"
#include <windows.h>
#include <iostream>
#include "structInfo.h"
using namespace std;
// HXSYDialog 对话框

IMPLEMENT_DYNAMIC(HXSYDialog, CDialogEx)

HXSYDialog::HXSYDialog(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG1, pParent)
	, str1(_T(""))
	, str2(_T(""))
{

}

HXSYDialog::~HXSYDialog()
{
}

void HXSYDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT1, str1);
	DDX_Text(pDX, IDC_EDIT2, str2);
}


BEGIN_MESSAGE_MAP(HXSYDialog, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &HXSYDialog::OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON2, &HXSYDialog::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON3, &HXSYDialog::OnBnClickedButton3)
	ON_BN_CLICKED(IDC_BUTTON4, &HXSYDialog::OnBnClickedButton4)
	ON_BN_CLICKED(IDC_BUTTON5, &HXSYDialog::OnBnClickedButton5)
	ON_BN_CLICKED(IDC_BUTTON6, &HXSYDialog::OnBnClickedButton6)
	ON_BN_CLICKED(IDC_BUTTON7, &HXSYDialog::OnBnClickedButton7)
	ON_BN_CLICKED(IDC_BUTTON8, &HXSYDialog::OnBnClickedButton8)
	ON_BN_CLICKED(IDC_BUTTON9, &HXSYDialog::OnBnClickedButton9)
	ON_BN_CLICKED(IDC_BUTTON11, &HXSYDialog::OnBnClickedButton11)
END_MESSAGE_MAP()


// HXSYDialog 消息处理程序


void HXSYDialog::OnBnClickedButton1()
{
	//自定义喊话内容
	BYTE str[100] = { 0x16,0x00,0x7E,0x00,0x00,0x00,0x00,0x07,0x00,0xBE,0xA4,0x20,0xA7,0x41,0xA6,0x6E,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
	DWORD pack_size = 0x18;
	CallSpeak(pack_size,(DWORD)str);
}


void HXSYDialog::OnBnClickedButton2()
{
	CallSend();
}


void HXSYDialog::OnBnClickedButton3()
{
	CallSendReduction();
}


void HXSYDialog::OnBnClickedButton4()
{
	CallRecv();
}


void HXSYDialog::OnBnClickedButton5()
{
	CallRecvReduction();
}


void HXSYDialog::OnBnClickedButton6()
{
	UpdateData(TRUE);
	CString str1 = str1;
	CString str2 = str2;
	int pack_size = strtol((const char*)CW2A(str1.GetBuffer(0)), NULL, 16);


	string str = CW2A(str2.GetString());
	CallPrintInfo("幻想神域  str2:%s\n", str);
	byte p[0x200];
	int len = str.size() / 2;
	for (int i = 0; i < len; i++)
	{
		p[i] = Call_2字符转Byte(str[2 * i], str[2 * i + 1]);//2char 转btye4
	}
	
	//发送封包
	CallSpeak(pack_size, (DWORD)p);
}


void HXSYDialog::OnBnClickedButton7()
{

	Attribute people;
	people.Init();
	CallPrintInfo("幻想神域   血量:最大血量 %d:%d / 人物坐标: X:%f Y:%f Z:%f\n", people.blood, people.bloodMax, people.X, people.Y, people.Z);;

}


void HXSYDialog::OnBnClickedButton8()
{
	ObjArr obj_arr;
	obj_arr.Init();
	for (int i = 0; i < (int)obj_arr.num; i++)
	{
		CallPrintInfo("幻想神域  血量:%d\n", obj_arr.list[i].blood);
	}
}


void HXSYDialog::OnBnClickedButton9()
{
	ObjList obj_list;
	obj_list.Init();
	for (int i = 0; i < (int)obj_list.num; i++)
	{
		CallPrintInfo("幻想神域 名称:%s 对象:%x 血量:%d/%d 坐标:%f/%f/%f 距离:%f\n", obj_list.list[i].gbkName, obj_list.list[i].obj,obj_list.list[i].blood, obj_list.list[i].bloodMax, obj_list.list[i].X, obj_list.list[i].Y, obj_list.list[i].Z, obj_list.list[i].distance);
		//CallPrintInfo("幻想神域 对象:%x 角色坐标:%f/%f/%f 怪物坐标:%f/%f/%f 距离:%f\n", obj_list.list[i].obj,obj_list.X, obj_list.Y,obj_list.Z,  obj_list.list[i].X, obj_list.list[i].Y, obj_list.list[i].Z, obj_list.list[i].distance);
	}
}




void HXSYDialog::OnBnClickedButton11()
{
	ObjList obj_list;
	obj_list.GetLateMonster();
	for (int i = 0; i < (int)obj_list.num; i++)
	{
		CallPrintInfo("幻想神域 名称:%s 对象:%x 血量:%d/%d 坐标:%f/%f/%f 距离:%f\n", obj_list.list[i].gbkName, obj_list.list[i].obj, obj_list.list[i].blood, obj_list.list[i].bloodMax, obj_list.list[i].X, obj_list.list[i].Y, obj_list.list[i].Z, obj_list.list[i].distance);
		//CallPrintInfo("幻想神域 对象:%x 角色坐标:%f/%f/%f 怪物坐标:%f/%f/%f 距离:%f\n", obj_list.list[i].obj,obj_list.X, obj_list.Y,obj_list.Z,  obj_list.list[i].X, obj_list.list[i].Y, obj_list.list[i].Z, obj_list.list[i].distance);
	}
}
